<?php
$this->Html->scriptBlock($scriptSearchBox, array('inline' => false));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<div class="searchbox" style="margin-top: 15px;">
    Bank&nbsp;<select id="match_bank_id" name="match_bank" style="padding:2px 0; width: 100px;">
        <option value="all">All</option>
        <?php echo $banks; ?>
    </select>
    &nbsp;&nbsp;From &nbsp;<input type="text" id="match_from_id" readonly="readonly" value="<?php echo date('m/d/Y', strtotime($from)); ?>" class="sel-date" name="match_from" />
    &nbsp;&nbsp;To &nbsp;<input type="text" id="match_to_id" readonly="readonly" value="<?php echo date('m/d/Y', strtotime($to)); ?>" class="sel-date" name="match_to" />
    <input type="button" id="search_button" value="Match" class="searchbutton" />
</div>
<div class="wrapper-table clearfix" style="margin-top:20px;">
    <span style="width:20px; height:20px; display:block; float:left; margin-left: 15px; background-color:#529214;"></span> 
    <span style="float:left;">&nbsp;MATCHED&nbsp;</span> 
    <span style="width:20px; height:20px; display:block; float:left; margin-left: 15px; background-color:#E6B800;"></span> 
    <span style="float:left;">&nbsp;NOT MATCHED&nbsp;</span> 
    <span style="width:20px; height:20px; display:block; float:left; margin-left: 15px; background-color:#ee5f5b;"></span> 
    <span style="float:left;">&nbsp;MATCHED all fields except AMOUNT&nbsp;</span> 
</div> 
<div class="wrapper-table clearfix"> 
    <table class="tbl-broking" border="1" style="border-top:0; border-left: 0;">
        <tr class="title-tbl" >
            <td style="border: none; background-color: #fff" colspan="2">AIH EXPENSES</td>
            <td width="10px" style="border: none; background-color: #fff"></td>
            <td colspan="4" style="border: none; background-color: #fff"></td>
            <td width="10px" style="border: none; background-color: #fff"></td>
            <td style="border: none; background-color: #fff" colspan="2">BANK TRANSACTIONS</td>
        </tr>
        <tr class="title-tbl" >
            <td style="border-top:1px solid #333333;">From</td>
            <td style="border-top:1px solid #333333;" width="120">Amount</td>
            <td width="10px" style="border-top:0; border-bottom:0; background-color: #fff"></td>
            <td style="border-top:1px solid #333333;" width="90">Date</td>
            <td style="border-top:1px solid #333333;" width="90">Bank Code</td>
            <td style="border-top:1px solid #333333;" width="90">Branch Code</td>
            <td style="border-top:1px solid #333333;" width="90">SWIFT</td>
            <td width="10px" style="border-top:0; border-bottom:0; background-color: #fff"></td>
            <td style="border-top:1px solid #333333;" width="120">Amount</td>
            <td style="border-top:1px solid #333333;">To</td>
        </tr>
        <?php
        foreach ($match_datas as $match_data) {
            $color = ' style="background-color: #529214;"';
            $color_from = '';
            $color_to = '';
            $from = $match_data['Bmatch']['name_of_bank'] . '<br />' . $match_data['Bmatch']['address_of_bank'];
            $to = $match_data['Bmatch']['e_name_of_bank'] . '<br />' . $match_data['Bmatch']['e_address_of_bank'];
            if($match_data['Bmatch']['status']==0) {
                $color = ' style="background-color: #ee5f5b;"';
            } else if($match_data['Bmatch']['status']==1) {
//                $color_to = ' background-color: #E6B800;';
                $color = ' style="background-color: #E6B800;"';
                $to = '<span style="color:#f00">No Data Available</span>';
            } else if($match_data['Bmatch']['status']==2) {
//                $color_from = ' background-color: #E6B800;';
                $color = ' style="background-color: #E6B800;"';
                $from = '<span style="color:#f00">No Data Available</span>';
            }
        ?>
        <tr class="line-content-tbl"<?echo $color; ?>>
            <td style="text-align: left; padding-left: 8px; <?echo $color_to; ?>"><?php echo $to; ?></td>
            <td style="text-align: right; padding-right: 8px; <?echo $color_to; ?>"><?php echo $match_data['Bmatch']['e_currency'] .' '. $match_data['Bmatch']['e_amount']; ?></td>
            <td width="10px" style="border-top:0; border-bottom:0; background-color: #fff"></td>
            <td style=""><?php echo date('m/d/Y', strtotime($match_data['Bmatch']['date'])); ?></td>
            <td style=""><?php echo $match_data['Bmatch']['bank_code']; ?></td>
            <td style=""><?php echo $match_data['Bmatch']['branch_code']; ?></td>
            <td style=""><?php echo $match_data['Bmatch']['swift_code']; ?></td>
            <td width="10px" style="border-top:0; border-bottom:0; background-color: #fff"></td>
            <td style="text-align: right; padding-right: 8px; <?echo $color_from; ?>"><?php echo $match_data['Bmatch']['currency'] .' '. number_format($match_data['Bmatch']['amount'], 2); ?></td>
            <td style="text-align: left; padding-left: 8px; <?echo $color_from; ?>"><?php echo $from; ?></td>
        </tr>
        <?php } ?>
    </table>
    <div class="wrapper-button-form">
        <div class="button-form">
            <div class="button-aihre button-blue"><?php echo $this->Html->link(__('NEW'), array('action' => 'add')); ?></div>
            <div class="button-aihre button-blue"><?php echo $this->Html->link(__('BANK RECONCILIATION '), array('action' => 'index')); ?></div>
        </div>
    </div>
</div>
<?php
$datePicker = "
    $(function() {
        $('#match_from_id').datepicker({ changeYear: true, dateFormat: 'm/d/yy'});
        $('#match_to_id').datepicker({ changeYear: true, dateFormat: 'm/d/yy'});
        return false;
    });";
$this->Html->scriptBlock($datePicker, array('inline' => false));
?>